<?php
/**
 * Group is an instance of CActiveRecord (sytem.db.ar). 
 *
 * CActiveRecord is the base class for classes representing relational data. 
 *
 * Eduow :  International system for education (http://www.eduow.com)
 * Copyright 2010, Nikolay Stoitsev
 *
 * Licensed under GNU General Public License version 2
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2010
 * @link          http://eduow.com Eduow Project
 * @package       eduow
 * @subpackage    application.models
 * @inheritance   class Group >> CActiveRecord >> CModel >> CComponent
 * @implements    ArrayAccess, Traversable, IteratorAggregate
 * @since         Eduow v 0.0.3
 * @license       http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License version 2
 */

class Group extends ActiveRecord
{
	//user rankings
	//the value of these constants match a group id in the group table
	const GUEST=1;
	const USER=2;
	const TRANSLATOR=3;	
	const TEACHER=4;
	const MODERATOR=5;	
	const ADMIN=6;
	const SITE_ADMIN=7;

	/**
	 * Returns the static model of the specified AR class.
	 * This method is required by all child classes of CActiveRecord.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules() {
		return array(
			array('name','length','max'=>50),
			array('name', 'required'),
		);
	}
	
	public function getListed() {
		$a = $this->findAll();
		unset($a[0]); //removes "not logged in" level
		return $a;
	}

}
